<template>
  <div>
    <el-upload
      class="upload-demo"
      action=url1
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :file-list="fileList"
      show-file-list:true
      list-type="picture"
    >
      <el-button size="small" type="primary">点击上传</el-button>
      <div slot="tip" class="el-upload__tip">
        只能上传jpg/png文件，且不超过500kb
      </div>
    </el-upload>
    <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
    <!-- ------------------------------------------ -->
    <el-upload
      ref="upload"
      :auto-upload="false"
      action="http://192.168.1.104:50000/test/upload"
    >
      <el-button size="small" type="primary">选择文件</el-button>
    </el-upload>

    <el-button size="small" type="primary" @click="upload">点击上传</el-button>
  </div>
</template>
<script>

export default {
  data() {
    return {
      // url1:'http://192.168.1.104:50000/test/upload',
      // url2:'3.jpg',
      url1:'http://192.168.1.104:50000/test/upload/3.jpg',
      fileList: [
        {
          name: "food.jpeg",
          url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
        {
          name: "food2.jpeg",
          url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
      ],
    };
  },
  methods: {
    handleRemove(file, fileList) {
      // console.log(file, fileList, "file,fileList");
    },
    handlePreview(file, fileList) {
      // console.log(file, fileList, "test");
    },
    upload() {
      // 其中 upload 对应的是上传组件中的 ref 的值, submit() 是固定的
      this.$refs.upload.submit();
      let id = 1

    },
    uploadWord(params) {
      // console.log(params.file);
    },
  },
};
</script>